package com.school.hjt.schoolclasscard.db;


import com.school.hjt.schoolclasscard.BaseApplication;
import com.school.hjt.schoolclasscard.bean.HomeBean;

import java.util.List;

/**
 * Created by xqx on 2017/10/27.
 * 数据库操作
 */

public class CardDao {

    /**
     * @param shop
     * 添加卡号
     */
    public static void insertCard(Cardnumber shop) {
        BaseApplication.getDaoInstant().getCardnumberDao().insertOrReplace(shop);
    }
    public static void insertCardList(List<Cardnumber> shop) {
        BaseApplication.getDaoInstant().getCardnumberDao().insertOrReplaceInTx(shop);
    }
    public static void insertStudenList(List<CardStudent> student_card){
//        BaseApplication.getDaoInstant().getCardStudentDao().insertOrReplace(student_card);
        BaseApplication.getDaoInstant().getCardStudentDao().insertOrReplaceInTx(student_card);

    }
    /**
     * @param shop
     * 更新签到数据
     */
    public static void updateSign(StudentSign shop) {
        BaseApplication.getDaoInstant().getStudentSignDao().update(shop);
    }
    /**
     * @param sign
     * 添加签到数据
     */
    public static void insertSign(StudentSign sign) {
        BaseApplication.getDaoInstant().getStudentSignDao().insertOrReplace(sign);
    }
    /**
     * @param shop
     * 添加
     */
    public static void insertDynamicSchool(DynamicSchool shop) {
        BaseApplication.getDaoInstant().getDynamicSchoolDao().insertOrReplace(shop);
    }
    public static List<StudentSign> querySignId(String id) {
        return BaseApplication.getDaoInstant().getStudentSignDao().queryBuilder().where(StudentSignDao.Properties.Signtype.eq(id)).list();
    }
    public static List<DynamicSchool> queryDynamicSchoolId(String id) {
        return BaseApplication.getDaoInstant().getDynamicSchoolDao().queryBuilder().where(DynamicSchoolDao.Properties.Id.eq(id)).list();
    }
    public static List<DynamicSchool> queryDynamicSchool() {
        return BaseApplication.getDaoInstant().getDynamicSchoolDao().queryBuilder().list();
    }
    public static void insertLabours(Labours shop) {
        BaseApplication.getDaoInstant().getLaboursDao().insertOrReplace(shop);
    }
    public static List<Labours> queryLaboursId(String id) {
        return BaseApplication.getDaoInstant().getLaboursDao().queryBuilder().where(LaboursDao.Properties.Id.eq(id)).list();
    }
    public static List<Labours> queryLabours() {
        return BaseApplication.getDaoInstant().getLaboursDao().queryBuilder().orderAsc(LaboursDao.Properties.Now_date).list();
    }
    /**
     * @param id
     * @return 返回搜到的id的卡号数据
     * 查询卡号id
     */
    public static List<Cardnumber> queryLove(String id) {
        return BaseApplication.getDaoInstant().getCardnumberDao().queryBuilder().where(CardnumberDao.Properties.Cardnumber.eq(id)).list();
    }
    public static List<Cardnumber> queryLoveID(String id) {
        return BaseApplication.getDaoInstant().getCardnumberDao().queryBuilder().where(CardnumberDao.Properties.Id.eq(id)).list();
    }

    /**
     * @param student_card
     * 添加学生
     */
    public static void insertStuden(CardStudent student_card){
        BaseApplication.getDaoInstant().getCardStudentDao().insertOrReplace(student_card);
    }

    /**
     * @return 返回学生数据
     */
    public static List<CardStudent> queryStudent() {
        return BaseApplication.getDaoInstant().getCardStudentDao().queryBuilder().list();
    }
    /**
     * @param id
     * @return 返回指定id的学生数据
     */
    public static List<CardStudent> queryStudentId(String id) {
        return BaseApplication.getDaoInstant().getCardStudentDao().queryBuilder().where(CardStudentDao.Properties.Id.eq(id)).list();
    }
    /**
     * @return 返回签到数据
     */
    public static List<StudentSign> querySign() {
        return BaseApplication.getDaoInstant().getStudentSignDao().queryBuilder().list();
    }
    public static void updateStudent(CardStudent shop) {
        BaseApplication.getDaoInstant().getCardStudentDao().update(shop);
    }
    /**
     * @param id
     * @return 返回指定id的数据
     */
    public static List<SchArticle> querySchArticle(String id) {
        return BaseApplication.getDaoInstant().getSchArticleDao().queryBuilder().where(SchArticleDao.Properties.Id.eq(id)).list();
    }
    /**
     * @param id
     * @return 返回指定id的数据
     */
    public static List<SchAboutUs> querySchAboutUs(String id) {
        return BaseApplication.getDaoInstant().getSchAboutUsDao().queryBuilder().where(SchAboutUsDao.Properties.Id.eq(id)).list();
    }
    /**
     * @param shop
     * 添加轮播图和班级荣誉相册
     */
    public static void insertAlbum(ClassAlbum shop) {
        BaseApplication.getDaoInstant().getClassAlbumDao().insertOrReplace(shop);
    }
    /**
     * @param shop
     * 添加数据
     */
    public static void insertClassAlbum(Album shop) {
        BaseApplication.getDaoInstant().getAlbumDao().insertOrReplace(shop);
    }
    /**
      * @param id
     * @return 返回指定id的数据
     */
    public static List<Album> queryClassAlbumId(String id) {
        return BaseApplication.getDaoInstant().getAlbumDao().queryBuilder().where(AlbumDao.Properties.Id.eq(id)).list();
    }
    public static List<Album> queryClassAlbum() {
        return BaseApplication.getDaoInstant().getAlbumDao().queryBuilder().list();
    }
    /**
     * @param id
     * @return 返回指定id的数据
     */
    public static List<ClassAlbum> queryAlbumId(String id) {
        return BaseApplication.getDaoInstant().getClassAlbumDao().queryBuilder().where(ClassAlbumDao.Properties.Id.eq(id)).list();
    }
    /**
     * @param id
     * @return 返回指定id的数据
     */
    public static List<ClassAlbum> queryAlbumType(String id) {
        return BaseApplication.getDaoInstant().getClassAlbumDao().queryBuilder().where(ClassAlbumDao.Properties.Typeid.eq(id)).list();
    }
    /**
     * @return 返回轮播图和荣誉相册图片
     */
    public static List<ClassAlbum> queryAlbum() {
        return BaseApplication.getDaoInstant().getClassAlbumDao().queryBuilder().list();
    }
    public static List<Album> queryAlbum1() {
        return BaseApplication.getDaoInstant().getAlbumDao().queryBuilder().list();
    }
    /**
     * @param student_card
     * 添加学校信息
     */
    public static void insertInfo(SchInfo student_card){
        BaseApplication.getDaoInstant().getSchInfoDao().insertOrReplace(student_card);
    }
    public static void insertClassInfo(ClassInfo student_card){
        BaseApplication.getDaoInstant().getClassInfoDao().insertOrReplace(student_card);
    }

    /**
     * @param schArticle
     * 添加信息
     */
    public static void insertAchArticle(SchArticle schArticle){
        BaseApplication.getDaoInstant().getSchArticleDao().insertOrReplace(schArticle);
    }
    /**
     * @param schAboutUs
     * 添加信息
     */
    public static void insertSchAboutUs(SchAboutUs schAboutUs){
        BaseApplication.getDaoInstant().getSchAboutUsDao().insertOrReplace(schAboutUs);
    }
    /**
     *
     * @return 返回数据
     */
    public static List<SchInfo> querySchInfo() {
        return BaseApplication.getDaoInstant().getSchInfoDao().queryBuilder().list();
    }
    /**
     * @param id
     * @return 返回指定id的数据
     */
    public static List<SchInfo> querySchInfoId(String id) {
        return BaseApplication.getDaoInstant().getSchInfoDao().queryBuilder().where(SchInfoDao.Properties.Id.eq(id)).list();
    }
    public static List<ClassInfo> queryClassInfo() {
        return BaseApplication.getDaoInstant().getClassInfoDao().queryBuilder().list();
    }
    /**
     * @return 返回数据
     */
    public static List<SchArticle> querySchArticle() {
        return BaseApplication.getDaoInstant().getSchArticleDao().queryBuilder().orderDesc(SchArticleDao.Properties.Sort).list();
    }
    /**
     * @return 返回数据
     */
    public static List<SchArticle> querySchArticleId(String id) {
        return BaseApplication.getDaoInstant().getSchArticleDao().queryBuilder().where(SchArticleDao.Properties.Id.eq(id)).list();
    }
    /**
     * @return 返回数据
     */
    public static List<SchAboutUs> querySchAboutUs() {
        return BaseApplication.getDaoInstant().getSchAboutUsDao().queryBuilder().orderDesc(SchAboutUsDao.Properties.Sort).list();
    }
}
